/*
-------------------------------------------------------------------
BIE is Copyright 2001-2003 Brunswick Corp.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/bie_license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
*/
package com.webdeninteractive.sbie.service;

import com.webdeninteractive.sbie.Service;
import com.webdeninteractive.sbie.Client;
import com.webdeninteractive.sbie.ProtocolHandler;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.HashMap;

/**
 * SBIE Service to print the current time to stdout.
 *
 * @version $Id: ClockService.java,v 1.1.1.1 2003/05/20 16:56:49 gdf Exp $ 
 * @author gfast
 */
public class ClockService
    extends ServiceBase 
    implements Service
{
    /** Have this service perform its task. */
    public void runService() {
        String format = getParameter("format");
        SimpleDateFormat df;
        if ( format == null ) {
            df = new SimpleDateFormat();
        } else {
            df = new SimpleDateFormat( format );
        }
        Date now = new Date( System.currentTimeMillis() );
        System.out.println( df.format(now) );
    }

    public Map getRequiredParameters() {
        HashMap p = new HashMap();
        p.put( "format", "Format string, suitable for java.text.SimpleDateFormat.  Defaults to the locale's default format." );
        return p;
    }

}
